package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter@Setter
public class StrategyDetail extends BaseDomain{
    public static final int STATE_NORMAL = 0 ;//草稿
    public static final int STATE_RELEASE = 1 ;//发布

    private String title;

    private Date createTime;

    @DateTimeFormat(pattern = "y-M-d")
    private Date releaseTime;

    private Integer sequence;

    private StrategyCatalog catalog;

    private String coverUrl;

    private Integer state;

    //文章内容
    private StrategyContent strategyContent;


    public String getJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("sequence",sequence);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if (catalog!=null){
            map.put("catalogId",catalog.getId());
            //攻略对象
            if(catalog.getStrategy()!=null){
                map.put("strategyId", catalog.getStrategy().getId());
            }
        }
        return JSONUtil.toJSONString(map);

    }

}